package com.flexcloudsdk.fetch;

import java.util.logging.Logger;


import com.google.appengine.api.urlfetch.FetchOptions;

public class CloudFetchOptions {
	private static final Logger log = Logger.getLogger(CloudFetchOptions.class.getName());
	private FetchOptions fetchOptions;
	private String sourceClass;
	private String sourceMethod;

	public CloudFetchOptions() {
		log.info("CloudFactoryOptions has been created by BlazeDS");
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		sourceClass = CloudFetchOptions.class.getName();
	}
	
	public CloudFetchOptions(FetchOptions value) {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);
		fetchOptions = value;
	}
	
	public void setOptions(FetchOptions value) {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);
		fetchOptions = value;
	}
	
	public void allowTruncate() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);
		fetchOptions.allowTruncate();
	}

	public void disallowTruncate() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);
		fetchOptions = fetchOptions.disallowTruncate();
	}
	
	public void  doNotFollowRedirects() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);
		fetchOptions = fetchOptions.doNotFollowRedirects();
	}
	
	public void doNotValidateCertificate() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);
		fetchOptions = fetchOptions.doNotValidateCertificate();
	}
	
	public void followRedirects() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);
		fetchOptions = fetchOptions.followRedirects();
	}
	
	public void setDeadline(Double deadline) {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);
		fetchOptions = fetchOptions.setDeadline(deadline);
	}
	
	public void validateCertificate() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		fetchOptions = fetchOptions.validateCertificate();
	}
	
	
}
